package com.finger.forest.adapter;

import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.finger.forest.R;
import com.finger.forest.model.FireInfoModel;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.List;

/**
 * @author sy
 * @date 2021/2/6
 * @desc
 */
public class FireInfoAdapter extends BaseQuickAdapter<FireInfoModel, BaseViewHolder> {
    public FireInfoAdapter(int layoutResId, @Nullable List<FireInfoModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FireInfoModel item) {
        RoundedImageView rivSynchronization = helper.getView(R.id.rivSynchronization);

        CheckBox cbNotice = helper.getView(R.id.cbDataSynchronization);
        //是否选中
        cbNotice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    item.setSelect(true);
                } else {
                    item.setSelect(false);
                }
            }
        });

        TextView tvName = helper.getView(R.id.tvName);
        String title = "火场采集";
        rivSynchronization.setBackgroundResource(R.mipmap.icon_site_of_a_fire);
        tvName.setText(title);
    }
}
